package com.diaohw.module.metadata;

import com.diaohw.module.metadata.obj.entity.MetaItemDO;
import com.diaohw.platform.framework.db.obj.BaseModel;
import io.swagger.v3.oas.annotations.media.Schema;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;

public class App {
    public static void main(String[] args) {
//        MybatisGenerator generator = MybatisGenerator.builder()
//                .url("jdbc:mysql://127.0.0.1:3306/platform_meta")
//                .username("root")
//                .password("123456")
//                .author("D-Hw")
//                .tables(List.of(
//                        "META_ITEM"))
//                .baseClass(App.class)
//                .build();
//
//        generator.generate();

        ArrayList<Field> list = new ArrayList<>();
        list.addAll(Arrays.asList(BaseModel.class.getDeclaredFields()));
        list.addAll(Arrays.asList(MetaItemDO.class.getDeclaredFields()));
        for (Field field : list) {
            if (!field.isAnnotationPresent(Schema.class)) {
                continue;
            }
            String description = field.getAnnotation(Schema.class).description();
            String name = field.getName();
            String simpleName = field.getType().getSimpleName();
            System.out.printf("%s\t%s\t%s\n", name, simpleName, description);
//            System.out.printf("-%s: %s\n", name, simpleName);
        }
        System.out.println(list.size());
    }
}
